/******************************************************************************
 * HelloWorldBean.java - created by Sakai App Builder -AZ
 * 
 * Copyright (c) 2008 Sakai Project/Sakai Foundation
 * Licensed under the Educational Community License version 1.0
 * 
 * A copy of the Educational Community License has been included in this 
 * distribution and is available at: http://www.opensource.org/licenses/ecl1.php
 * 
 *****************************************************************************/

package org.sakaiproject.jsfdemo.tool.jsf;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.sakaiproject.user.api.UserDirectoryService;

import bk.Section;


public class HelloWorldBean {

	private static Log log = LogFactory.getLog(HelloWorldBean.class);
	String yourname="nanana";
   Section qSection= new Section();
	private UserDirectoryService userDirectoryService;
   
   public void setUserDirectoryService(UserDirectoryService userDirectoryService) {
      this.userDirectoryService = userDirectoryService;
   }


	public HelloWorldBean() {
	}

	public Date getCurrentDate() {
		log.debug("Returning current date...");
		return new Date();
	}

	public String getCurrentUserDisplayName() {
      try {
         return userDirectoryService.getCurrentUser().getDisplayName();
      } catch (Exception e) {
         log.warn("Cannot get current user display name");
         return "--------";
      }
	}


	public String getYourname() {
		return yourname;
	}


	public void setYourname(String yourname) {
		this.yourname = yourname;
	}
	public String showMe(){
		yourname=getCurrentUserDisplayName();
		return "HelloWorld";
	}
	public String goCreate(){
		return "editPage";
	}


	public Section getqSection() {
		return qSection;
	}


	public void setqSection(Section qSection) {
		this.qSection = qSection;
	}
	
}
